<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.jieSuan.zhiHangLieBiao"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>

<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">

    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class=" form-inline">
                
                     <div class="form-group form-group-xs">
                        <label for="searchrecpAddr"><spring:message code="message.jieSuan.kaiHuHangHangHao"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <input class="form-control" type="text" id="bankCode" name="bankCode" placeholder="<spring:message code="message.jieSuan.kaiHuHangHangHao"/>" />
                    </div>
                    
                     <div class="form-group form-group-xs">
                        <label for="searchrecpAddr"><spring:message code="message.jieSuan.kaiHuHangHangMing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <input class="form-control" type="text" id="bankName" name="bankName" placeholder="<spring:message code="message.jieSuan.kaiHuHangHangMing"/>" />
                    </div>
                    
                    <!-- 勿动  此为暂时性注释，等地区数据修复后在进行使用 -->
                    <%--  <div class="form-group form-group-xs">
                        <label for="searchAreaName"><spring:message code="message.jieSuan.kaiHuHangQuYu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <select class="form-control" id="area1" name="area1">
                            <option value=''>请选择</option>
                        </select>
                        <select class="form-control" id="area2" name="area2">
                            <option value=''>请选择</option>
                        </select>
                        <select class="form-control" id="area3" name="area3">
                            <option value=''>请选择</option>
                        </select>
                    </div>    --%>
                    
                    <button type="button" class="btn btn-success btn-sm" onclick="search()"><spring:message code="message.button.seachSpacing"/></button>
                    
                </div>
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        
        <div class=" box box-warning bottongroup">
            <button type="button" id="confirm"  onclick="confirm();" class="btn btn-default btn-sm"><spring:message code="message.button.okSpacing"/></button>
        </div>
             
    </section>
    
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
        function showFocus(rowId) {
            $("#gridlist").resetSelection();
            $("#gridlist").setSelection(rowId);
        }
    
        $(function () {
            $("#gridlist").jqGrid({
            	url: "${ctx}/acctInfo/getSubBankList.html",
                mtype: "POST",
                postData:{"bankAcctNo":"${bankAcctNo}"},
                datatype: "json",
                autowidth: true,
                height: 270,
                colNames: [
                           '<spring:message code="message.jieSuan.kaiHuHangHangHao"/>',
                           '<spring:message code="message.jieSuan.kaiHuHangHangMing"/>',
                           '<spring:message code="message.jieSuan.kaiHuHangQuYu"/>',
                           '<spring:message code="message.jieSuan.kaiHuHangQuYu"/><spring:message code="message.yanZheng.bianMa"/>'
                           ],
                colModel: [
                    { name: 'bankCode', width: 60 , align:"center",sortable: false},
                    { name: 'bankName', width: 60 , align:"center",sortable: false },
                    { name: 'areaName', width: 60 , align:"center",sortable: false },
                    { name: 'areaCode',hidden:true, width: 80 , align:"center" ,sortable: false}
                ],
                rowNum: 20,
                rowList: [20, 40, 60, 100],
                rownumbers: true,
                multiselect: false,
                pager: "#gridpage",
                viewrecords: true,
                caption: "<spring:message code="message.jieSuan.zhiHangLieBiao"/>",
                jsonReader: {
                    repeatitems: false,
                    id: "bankCode"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
            
            $.post("${ctx}/acctInfo/getBankAreaList.html", {
            	"provinceCode": "0", 
            	"cityCode":"0"
            }, function(result) {
            	if (result.success) {
            		var list = result.rows;
            		if (list.length > 0) {
            			$("#area1").children(":not(:first)").remove();
            			for (var i=0; i<list.length; i++) {
            				var item = list[i];
            				$("#area1").append("<option value='" + item.areaCode + "'>" + item.areaName + "</option>");
            			}
            		}
            	}
            }, "json");
            
            $("#area1").change(function() {
            	$("#area2").children(":not(:first)").remove();
            	$("#area3").children(":not(:first)").remove();
            	$.post("${ctx}/acctInfo/getBankAreaList.html", {
                    "provinceCode": $("#area1").val(), 
                    "cityCode":"0"
                }, function(result) {
                    if (result.success) {
                        var list = result.rows;
                        if (list.length > 0) {
                            for (var i=0; i<list.length; i++) {
                                var item = list[i];
                                $("#area2").append("<option value='" + item.areaCode + "'>" + item.areaName + "</option>");
                            }
                        }
                    }
                }, "json");
            });
            
            $("#area2").change(function() {
                $("#area3").children(":not(:first)").remove();
                $.post("${ctx}/acctInfo/getBankAreaList.html", {
                    "provinceCode": $("#area1").val(), 
                    "cityCode": $("#area2").val()
                }, function(result) {
                    if (result.success) {
                        var list = result.rows;
                        if (list.length > 0) {
                            for (var i=0; i<list.length; i++) {
                                var item = list[i];
                                $("#area3").append("<option value='" + item.areaCode + "'>" + item.areaName + "</option>");
                            }
                        }
                    }
                }, "json");
            });
            
       });
       
       
       /* 查询 */
       function search(page) {
           var bankCode = $.trim($("#bankCode").val());
           var bankName = $.trim($("#bankName").val());
           var bankAreaId = $.trim($("#area3").val());
           if(bankAreaId == null || bankAreaId==""){
        	   bankAreaId=$.trim($("#area2").val());
           }
           if(bankAreaId == null || bankAreaId==""){
               bankAreaId=$.trim($("#area1").val());
           }
           $("#gridlist").jqGrid("clearGridData");
               $("#gridlist").jqGrid('setGridParam',{  
               mtype: "POST",
               datatype:'json',
               postData:{
                   "bankCode":bankCode,
                   "bankName":bankName,
                   "bankAreaId":bankAreaId
               },
               page : (page || 1)
           }).trigger("reloadGrid"); //重新载入  
       }
       
       
       //确认
       function confirm() {
           var rowId = $("#gridlist").jqGrid("getGridParam", "selrow") || [];
            if(rowId.length <=0){
               $.HN.message.alert("<spring:message code="message.lable.pleaseSelectOperational"/><spring:message code="message.jieSuan.kaiHuHang"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
               return;
            }
            var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
            var dialog = top.dialog.get(window);
            var params = {
            	"bankCode" : rowdata.bankCode,
            	"bankName" : rowdata.bankName,
            	"areaCode" : rowdata.areaCode,
            	"areaName" : rowdata.areaName
            };
            dialog.close(params);   // 关闭（隐藏）对话框
            dialog.remove();        // 主动销毁对话框
       }

     
        
    </script>
</body>
</html>